home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
lcppb.zip
/
LCPPANS.ZIP
/
CUBE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-08
|
816b
|
36 lines
// cube.cpp -- Find area of cubes and squares
#include <iostream.h>
double area(double x, double y, double z = 0);
main()
{
double x, y, z;
cout << "\nEnter three values to find the area of a cube.";
cout << "\nType 0 for the third value for a square.";
cout << "\nFor example, type 2 4 8, or 2 4 0.\n";
cin >> x >> y >> z;
if (z == 0)
cout << "Area of square == " << area(x, y);
else
cout << "Area of cube == " << area(x, y, z);
}
double area(double x, double y, double z)
{
double result = x * y;
if (z != 0)
result *= z;
return result;
}
// Copyright (c) 1990 by Tom Swan. All rights reserved
// Revision 1.00 Date: 12/04/1990 Time: 05:40 pm
// Revision 1.01 Date: 07/08/1991 Time: 05:41 pm
// Converted for Borland C++ 2.0